//
//  DYSpeedTipsCell.m
//  PrivatePhoto
//
//  Created by  on 2020/10/17.
//  Copyright © 2020年 . All rights reserved.

#import "DYSpeedTipsCell.h"

@implementation DYSpeedTipsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setData:(id)data delegate:(id)delegate {
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[TTSpeedTipsCellModel class]]) {
            TTSpeedTipsCellModel *model = data[@"data"];
            
            if (model.type > 0) {
                _titleLabel.hidden = NO;
                if (model.type == 1) {
                    _titleLabel.text = @"测速中...";
                } else {
                    _titleLabel.text = [NSString stringWithFormat:@"本次测速已完成\n\n平均速度：%@",model.speedValue];
                }
            } else {
                _titleLabel.hidden = YES;
            }
        }
    }
}

@end


#pragma mark - Model

@implementation TTSpeedTipsCellModel

+ (TTSpeedTipsCellModel *)ittemModelWithType:(NSInteger)type speedValue:(NSString *)speedValue {
    TTSpeedTipsCellModel *model = [TTSpeedTipsCellModel new];
    model.type = type;
    model.speedValue = kSafeString(speedValue);
    return model;
}

@end
